package com.itheima.task;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 需求：每间隔五秒，向控制台输出当前时间
 */
@Component
public class QuickJob {

    // 定时任务方法声明：public修饰，没有返回值，没有形参
    // @Scheduled(fixedDelay =5000)
    //@Scheduled(cron = "0/5 * * * * ?")
    public void quick() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String format = sdf.format(new Date());
        System.out.println(format);
    }
}